<script type="text/javascript" src="/Inc/AspBox/jsLib/json2.js"></script>
<script type="text/javascript">
var myJSONObject = {"class1": [
        {"name": "张三", "gender": "男", "result": 65},
        {"name": "小红", "gender": "女", "result": 87},
        {"name": "小丽", "gender": "女", "result": 78}
    ]
};
var myJSONText = JSON.stringify(myJSONObject, replacer); //JS Object转成JSON字符串

function replacer(key, value) {
    if (typeof value === 'number' && !isFinite(value)) {
        return String(value);
    }
    return value;
}
document.writeln(myJSONText);

var myJSONtext2 = '{"name": "张三", "gender": "男", "result": 65}';
var myObject = eval('(' + myJSONtext2 + ')'); //JSON字符串转成 Object
var myObjData = JSON.parse(myJSONtext2, function (key, value) { //JSON字符串转成JS Object
    var type;
    if (value && typeof value === 'object') {
        type = value.type;
        if (typeof type === 'string' && typeof window[type] === 'function') {
            return new (window[type])(value);
        }
    }
    return value;
});

var text = JSON.stringify(myObjData, replacer); //JS Object转成JSON字符串
document.writeln(text);
</script>